<template>
	<view>
		<cu-custom v-if="customShow" bgColor="bg-ffffff" :isBack="true">
			<block slot="backText"></block>
			<block slot="content">申请添加朋友</block>
		</cu-custom>
		<scroll-view class="scrollPage bg-ffffff" refresher-background="#ffffff" scroll-y="true" :style="'height:'+(winHeight-barHeight)+'px'">
			<common-view :needLogin="hasLogin?'n':'y'" :zindex="997" :animationClass="animation" @closeAnimation="closeAnimation" :indicator="indicator"></common-view>
			<view class="padding">
				<text class="text-sm text-gray">发送添加朋友申请</text>
				<view class="bg-f7f7f7 padding-sm margin-top-sm radius">
					<textarea v-model="remark" auto-height="true" style="min-height:150upx;font-size:28upx;width:100%;"/>
				</view>
				<view class="flex justify-center margin-top">
					<button class="cu-btn bg-themeColor" style="padding:0 60upx">发 送</button>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex';
	import contactsObj from 'model/contactsModel.js';
	let disp = require("common/broadcast");
	let me = null;
	export default {
		data() {
			return {
				indicator: 0,
				animation:'',
				customShow:0,
				barHeight:0,
				remark:''
			};
		},
		onLoad() {
			me = this;
			this.barHeight = this.NativeBar;
			//#ifdef H5 || MP-BAIDU || MP-TOUTIAO || MP-WEIXIN
			this.customShow = 1;
			this.barHeight = this.CustomBar;
			//#endif
			me.remark = '我是'+me.userInfo.username;
		},
		onReady() {
			
		},
		computed: {
			...mapState({
				winHeight: ({
					baseModule
				}) => baseModule.winHeight,
				hasLogin: ({
					userModule
				}) => userModule.hasLogin,
				userInfo: ({
					userModule
				}) => userModule.userInfo,
			})
		},
		methods:{
			...mapMutations(['chatModule/setChatTo']),
			closeAnimation() {
				this.animation = "";
				this.indicator = 0;
			},
			getData(){
				contactsObj.search(me,{
					keyword:me.keyword
				}).then(res => {
					console.log(res)
					me.searched = 1;
					me.pageData=res.info;
					if(me.pageData){
						uni.navigateTo({
							url:"../../pages1/contacts/profile?uid="+me.pageData.user_id
						});
					}
					me.$util.closeIndicator(me);
				}).catch(err => {
					me.searched = 1;
					console.log(err);
				});
			},
			doSearch(){
				me.getData();
			},
			clearKeyword(){
				me.keyword='';
				me.pageData=null;
			},
			inputEvent(){
				me.searched=0;
			}
		}
	}
</script>

<style>
.cu-list.menu-avatar>.cu-item .content{
	left: 114upx;
	width: calc(100% - 24upx - 70upx - 50upx );
}
</style>

